package linwen.wang.schedule.springboot;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

// @Component
@Slf4j
// @EnableScheduling
public class TestSpringbootSchedule {
    private int i = 1;


    @Scheduled(cron = "0/2 * * * * ?")
    public void testSchedul() {
        log.info("cron schedul {}",i++);
    }

    @Scheduled(fixedRate = 2000) // 任务每隔 5 秒执行一次
    public void testSchedu2() {
        log.info("fixedRate schedul {}",i++);
    }
    @Scheduled(fixedDelay= 2000)	// 任务每隔 5 秒执行一次(上一次任务结束5秒后, 再执行下一次任务)
    public void testSchedu3() {
        log.info("fixedDelay schedul {}",i++);
    }
}
